<!--  -->
<template>
<div class='card-page'>
  <van-popup v-model="cardTypeShow" position="bottom" :style="{ height: '50%' }" @close="cardClose" round>
    <div class="card-content">
      <div class="card-head flex-j-sb flex-a-c">
        <div class="card-close" @click="cardClose">取消</div>
        <div class="card-title">{{cardTitle}}</div>
        <div class="card-confrim" @click="cardConfrim">确定</div>
      </div>
      <div class="card-main">
        <div class="card-list">
          <block v-for="(item,index) in cardArr" :key="index">
            <div class="card-item flex-a-c flex-j-sb" @click.stop="cardTypeOn(item,index)" :class="cardIndex == index?'active-color':''">
              <h3>{{item.name}}</h3>
              <span class="iconfont icon-all_select_choose" v-show="cardIndex == index"></span>
            </div>
          </block>
        </div>
      </div>
    </div>
  </van-popup>
</div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  name:'',
  props: {
    cardTypeShow:Boolean,
    cardArr:Array,
    cardTitle:String,
    cardIndex:Number
  },
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    return {
      // cardTypeIndex:0,
      cardVal:'',
      cardName:''
    };
  },
//监听属性 类似于data概念
computed: {},
//监控data中的数据变化
watch: {},
//方法集合
methods: {
  cardTypeOn(item,index) {
    console.log(item);
    this.cardIndex = index;
    this.cardVal = item.value;
    this.cardName = item.name;
  },
  cardClose() {
    // this.cardTypeShow = false;
    this.$emit('update:cardTypeShow',false)
    console.log(this.cardTypeShow);
  },
  cardConfrim() {
    this.$emit('update:cardTypeShow',false)
    this.$emit('cardConfrim',{cardIndex:this.cardIndex})
  }
},
//生命周期 - 创建完成（可以访问当前this实例）
created() {

},
//生命周期 - 挂载完成（可以访问DOM元素）
mounted() {
  console.log(this.cardTypeShow);
},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style lang="scss" scoped>
/* @import url(); 引入公共css类 */
.card-content {
  .card-head {
    padding:1.25rem;
    .card-close {
      color: #AAAAB3;
      font-size: 1rem;
    }
    .card-title {
      font-weight: bold;
      font-size: 1rem;
      color: #00001C;
    }
    .card-confrim {
      font-weight: bold;
      font-size: 1rem;
      color: #00001C;
    }
  }
  .card-main {
    padding:0 1.25rem;
    .card-item {
      padding:1.25rem 0;
      border-bottom: 0.0625rem solid #F0F0F1;
      h3 {
        text-align: left;
        font-weight: 500;
        font-size: 0.875rem;
        color: #00001C;
      }
    }
    .active-color {
      h3 {
        color: #F15353;
      }
      .icon-all_select_choose {
        color: #F15353;
      }
    }
  }
}
</style>